import router from '@system.router';
import prompt from '@system.prompt';


export default {
    data: {
        storey:'',
        detail:'',
        selectList:["地震","火灾","洪水","泥石流"],
        listen:0,
        escape:0,
        disastercat:"地震",
        timecur:''

    },

    change(e){
        this.storey=e.value;
        console.log(this.storey);
    },
    selectChange(e){
        for(let i = 0;i<this.selectList.length;i++){
            if(e.newValue == this.selectList[i]){
                console.log(e.newValue);
                console.log(e.newValue);
                this.disastercat=e.newValue;
            }
        }

    },

    onRadioChangeN(inputValue, e) {
        if(e.checked){
            console.info("没听到");
            this.listen=0;
        }else{
            console.info("有听到");
            this.listen=1;
        }
    },
    onRadioChange0(inputValue, e) {

        if(e.checked){
            console.info("未避险");
            this.escape=0;
        }else{
            console.info("有避险");
            this.escape=1;
        }
    },
    handleTextInput(e){
        this.detail=e.value;
        console.log(this.detail);
    },
    //将避险调查数据上传到数据库中
    fankui:async function(){

        var time=new Date();
        this.timecur=time.getFullYear()+"/"+(time.getMonth()+1)+"/"+time.getDate()+"   "+time.toLocaleTimeString();
        var actionData = {};
        actionData.category = "避险调查";
        actionData.disastercat = this.disastercat;
        actionData.listen = this.listen;
        actionData.escape = this.escape;
        actionData.timec = this.timecur;


        var action = {};

        //添加service所在的包名
        action.bundleName = 'com.example.myapplication4';

        //添加service的类名
        action.abilityName = 'com.example.myapplication4.DemoService3';

        //添加messageCode ，用于区分其他的action
        action.messageCode = 200;

        //添加数据
        action.data = actionData;

        //跳转的activity的类型，0代表service
        action.abilityType = 0;

        //最重要的一步：跳转
        var str = await FeatureAbility.callAbility(action);

        //下面是处理 java FA 返回的数据
        var result = JSON.parse(str);
        console.log(result.ans);

        prompt.showToast({
            message: '提交成功',
            duration: 2000,
        });
        setTimeout(()=>{
            router.push({
                uri:'pages/firstpage/firstpage',

            })
        },2000);

    },
}
